package com.mongoplus.service.impl;

import com.mongoplus.conditions.query.QueryWrapper;
import com.mongoplus.entity.User;
import com.mongoplus.mapper.UserMapper;
import com.mongoplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserServiceImpl extends ServiceImpl<User> implements UserService {
    @Autowired
    private UserMapper userMapper;


    @Override
    public void savaUser() {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", "阮婷02");
        User user1 = userMapper.one(queryWrapper);
        if (user1 == null){
            user1 = new User();
            user1.setAge(22);
            user1.setUsername("阮婷02");
            user1.setPassword("123456");
            user1.setEmile("123456@qq.com");
            user1.setBirthday(LocalDateTime.of
                    (2003,7,23,12,30));
            userMapper.save(user1);
        }
    }
}
